package com.txsc.activity;
import lib.view.ViewUtils;
import lib.view.annotation.ViewInject;
import com.txsc.MyApplication;
import com.txsc.R;
import com.txsc.utils.AtyUtils;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings.ZoomDensity;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;
/**
* 商品描述界面,webView
*
* @author Admin
*
*/
public class Goods_DescAty extends Activity {
@ViewInject(R.id.p2_main_webview)
private WebView webView;
@ViewInject(R.id.p2_img_back)
private ImageView img_Back;
@ViewInject(R.id.p2_web_tv_car)
private TextView tv_Car;
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MyApplication.getInstance().addActivity(this);
setContentView(R.layout.p2_main_webview);
ViewUtils.inject(this);
String desc = getIntent().getStringExtra("desc");
String html = "<html>" + "<body>" + desc + "</body>" + "</html>";
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setHorizontalScrollBarEnabled(true);
webView.setHorizontalScrollbarOverlay(true);
webView.setInitialScale(10);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);
DisplayMetrics dm = getResources().getDisplayMetrics();
int scale = dm.densityDpi;
if (scale == 240) { //
webView.getSettings().setDefaultZoom(ZoomDensity.FAR);
} else if (scale == 160) {
webView.getSettings().setDefaultZoom(ZoomDensity.MEDIUM);
} else {
webView.getSettings().setDefaultZoom(ZoomDensity.CLOSE);
}
webView.loadDataWithBaseURL(null, html, "text/html", "utf-8", null);
img_Back.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
tv_Car.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
AtyUtils.turnToCar(Goods_DescAty.this);
}
});
}
}